package com.infotech.NginxMonitor.common;

import java.io.InputStreamReader;
import java.io.LineNumberReader;

public class Command {

	public String execute(String cmd) {
		String[] cmda = { "/bin/sh", "-c", cmd };
		try {
			Process process = Runtime.getRuntime().exec(cmda);
			LineNumberReader reader = new LineNumberReader(
					new InputStreamReader(process.getInputStream()));
			StringBuffer sb = new StringBuffer();
			String line;
			while ((line = reader.readLine()) != null) {
				sb.append(line).append("\n");
			}
			return sb.toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
